#pragma once

#include "pch.h"
#include "IndirectMonitor.h"

namespace indirect_disp {
    struct Direct3DDevice
    {
        Direct3DDevice() = delete;
        Direct3DDevice(LUID AdapterLuid) ;

        HRESULT Init();

		LUID AdapterLuid;
        winrt::com_ptr<ID3D11Device> Device;
        winrt::com_ptr<ID3D11DeviceContext> DeviceContext;
		};
	
		class SwapChainProcessor
		{
		public:
			/*SwapChainProcessor(IDDCX_SWAPCHAIN hSwapChain, std::shared_ptr<Direct3DDevice> Device,
				HANDLE NewFrameEvent, struct IndirectMonitor::MonitorContext* pMonitorContext);*/
			SwapChainProcessor(IDDCX_SWAPCHAIN hSwapChain, std::shared_ptr<Direct3DDevice> Device,
				HANDLE NewFrameEvent);
			~SwapChainProcessor();

		private:
			static DWORD CALLBACK RunThread(LPVOID Argument);

			void Run();
			void RunCore();
			bool bExit = false;

		public:
        IDDCX_SWAPCHAIN m_hSwapChain;
        std::shared_ptr<Direct3DDevice> m_Device;
        
        // A handle that points to 'RunThread' 
        winrt::handle m_hThread;

        // Imformed by IddCx framework that there's a new image available
        HANDLE m_hAvailableBufferEvent;

        // Informed by user or our driver to stop processing images
        winrt::handle m_hTerminateEvent;
		};
}


